import 'package:amway_superapp_creator_plugin/analysis/zhuge_edit.dart';
import 'package:amway_superapp_creator_plugin/config/colors_config.dart';
import 'package:amway_superapp_creator_plugin/dialog/loading_dialog.dart';
import 'package:amway_superapp_creator_plugin/routers/application.dart';
import 'package:amway_superapp_creator_plugin/utils/app_util.dart';
import 'package:amway_superapp_creator_plugin/utils/loading_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:flutter/cupertino.dart';

class LookBigImage extends StatelessWidget {
  String image;

  LookBigImage(this.image);

  @override
  Widget build(BuildContext context) {
    ZhugeEditAnalysis.editPage(EditPageType.reviewImage);

    return FlutterEasyLoading(
      child: CupertinoPageScaffold(
        child: Scaffold(
          appBar: AppBar(
            elevation: 0,
            backgroundColor: Colors.black,
            leading: IconButton(
              icon:
                  Icon(Icons.keyboard_arrow_left, color: Colors.white),
              onPressed: () {
                Application.router.pop(context);
              },
            ),
            centerTitle: true,
            title: Text(
              "查看图片",
              style: TextStyle(
                  color: Colors.white,
                  fontSize: ScreenUtil().setSp(18)),
            ),
          ),
          body: Container(
            child: Center(
              child: Image.network(image),
            ),
          ),
          bottomNavigationBar: builderBottomNavigationBar(context),
        ),
      ),
    );
  }

  Widget  builderBottomNavigationBar(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(right: ScreenUtil().setSp(16)),
      color: Colors.black,
      height: ScreenUtil().setHeight(100),
      child: Stack(
        children: [
          Align(
            alignment: Alignment.centerRight,
            child: FlatButton(
              shape: StadiumBorder(),
              onPressed: () {

                showDialog(
                  context: context,
                  builder: (ctx) {
                    return LoadingDialog(
                      canceledOnTouchOutside: false,
                      tipMsg: '正在保存',
                    );
                  },
                );
                AppUtil.saveImage(image, dowlondCallback: (data) {
                  Application.router.pop(context);
                });
              },
              color: ColorsConfig.c_396E75,
              disabledColor: ColorsConfig.c_396E75,
              splashColor: Colors.transparent,
              child: Text(
                '下载',
                style: TextStyle(
                  color: Colors.white,
                  fontSize: ScreenUtil().setSp(14),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
